Optimal. Leaf size=103 \[ \frac {2 (a c-b d)^2 \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {a+b}}\right )}{a^2 \sqrt {a-b} \sqrt {a+b} f}+\frac {d (2 a c-b d) \tanh ^{-1}(\sin (e+f x))}{a^2 f}+\frac {d^2 \tan (e+f x)}{a f} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.19, antiderivative size = 103, normalized size of antiderivative = 1.00, number of steps
used = 8, number of rules used = 7, integrand size = 25, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.280, Rules used = {2907, 3031,
2738, 211, 3855, 3852, 8} \begin {gather*} \frac {2 (a c-b d)^2 \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {a+b}}\right )}{a^2 f \sqrt {a-b} \sqrt {a+b}}+\frac {d (2 a c-b d) \tanh ^{-1}(\sin (e+f x))}{a^2 f}+\frac {d^2 \tan (e+f x)}{a f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 8
Rule 211
Rule 2738
Rule 2907
Rule 3031
Rule 3852
Rule 3855
Rubi steps
\begin {align*} \int \frac {(c+d \sec (e+f x))^2}{a+b \cos (e+f x)} \, dx &=\int \frac {(d+c \cos (e+f x))^2 \sec ^2(e+f x)}{a+b \cos (e+f x)} \, dx\\ &=\int \left (\frac {(a c-b d)^2}{a^2 (a+b \cos (e+f x))}+\frac {d (2 a c-b d) \sec (e+f x)}{a^2}+\frac {d^2 \sec ^2(e+f x)}{a}\right ) \, dx\\ &=\frac {d^2 \int \sec ^2(e+f x) \, dx}{a}+\frac {(a c-b d)^2 \int \frac {1}{a+b \cos (e+f x)} \, dx}{a^2}+\frac {(d (2 a c-b d)) \int \sec (e+f x) \, dx}{a^2}\\ &=\frac {d (2 a c-b d) \tanh ^{-1}(\sin (e+f x))}{a^2 f}-\frac {d^2 \text {Subst}(\int 1 \, dx,x,-\tan (e+f x))}{a f}+\frac {\left (2 (a c-b d)^2\right ) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (e+f x)\right )\right )}{a^2 f}\\ &=\frac {2 (a c-b d)^2 \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {a+b}}\right )}{a^2 \sqrt {a-b} \sqrt {a+b} f}+\frac {d (2 a c-b d) \tanh ^{-1}(\sin (e+f x))}{a^2 f}+\frac {d^2 \tan (e+f x)}{a f}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.92, size = 135, normalized size = 1.31 \begin {gather*} \frac {-\frac {2 (a c-b d)^2 \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2}}+d \left (-\left ((2 a c-b d) \left (\log \left (\cos \left (\frac {1}{2} (e+f x)\right )-\sin \left (\frac {1}{2} (e+f x)\right )\right )-\log \left (\cos \left (\frac {1}{2} (e+f x)\right )+\sin \left (\frac {1}{2} (e+f x)\right )\right )\right )\right )+a d \tan (e+f x)\right )}{a^2 f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.35, size = 165, normalized size = 1.60
method | result | size |
derivativedivides | \(\frac {\frac {2 \left (a^{2} c^{2}-2 c d a b +b^{2} d^{2}\right ) \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{2} \sqrt {\left (a -b \right ) \left (a +b \right )}}-\frac {d^{2}}{a \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )-1\right )}-\frac {d \left (2 a c -b d \right ) \ln \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )-1\right )}{a^{2}}-\frac {d^{2}}{a \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )+1\right )}+\frac {d \left (2 a c -b d \right ) \ln \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )+1\right )}{a^{2}}}{f}\) | \(165\) |
default | \(\frac {\frac {2 \left (a^{2} c^{2}-2 c d a b +b^{2} d^{2}\right ) \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{2} \sqrt {\left (a -b \right ) \left (a +b \right )}}-\frac {d^{2}}{a \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )-1\right )}-\frac {d \left (2 a c -b d \right ) \ln \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )-1\right )}{a^{2}}-\frac {d^{2}}{a \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )+1\right )}+\frac {d \left (2 a c -b d \right ) \ln \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )+1\right )}{a^{2}}}{f}\) | \(165\) |
risch | \(\frac {2 i d^{2}}{f a \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}+\frac {2 d \ln \left ({\mathrm e}^{i \left (f x +e \right )}+i\right ) c}{a f}-\frac {d^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}+i\right ) b}{a^{2} f}-\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) c^{2}}{\sqrt {-a^{2}+b^{2}}\, f}+\frac {2 \ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) c d b}{\sqrt {-a^{2}+b^{2}}\, f a}-\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) b^{2} d^{2}}{\sqrt {-a^{2}+b^{2}}\, f \,a^{2}}+\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) c^{2}}{\sqrt {-a^{2}+b^{2}}\, f}-\frac {2 \ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) c d b}{\sqrt {-a^{2}+b^{2}}\, f a}+\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) b^{2} d^{2}}{\sqrt {-a^{2}+b^{2}}\, f \,a^{2}}-\frac {2 d \ln \left ({\mathrm e}^{i \left (f x +e \right )}-i\right ) c}{a f}+\frac {d^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}-i\right ) b}{a^{2} f}\) | \(570\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 227 vs.
\(2 (97) = 194\).
time = 3.77, size = 527, normalized size = 5.12 \begin {gather*} \left [\frac {2 \, {\left (a^{3} - a b^{2}\right )} d^{2} \sin \left (f x + e\right ) - {\left (a^{2} c^{2} - 2 \, a b c d + b^{2} d^{2}\right )} \sqrt {-a^{2} + b^{2}} \cos \left (f x + e\right ) \log \left (\frac {2 \, a b \cos \left (f x + e\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (f x + e\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (f x + e\right ) + b\right )} \sin \left (f x + e\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (f x + e\right )^{2} + 2 \, a b \cos \left (f x + e\right ) + a^{2}}\right ) + {\left (2 \, {\left (a^{3} - a b^{2}\right )} c d - {\left (a^{2} b - b^{3}\right )} d^{2}\right )} \cos \left (f x + e\right ) \log \left (\sin \left (f x + e\right ) + 1\right ) - {\left (2 \, {\left (a^{3} - a b^{2}\right )} c d - {\left (a^{2} b - b^{3}\right )} d^{2}\right )} \cos \left (f x + e\right ) \log \left (-\sin \left (f x + e\right ) + 1\right )}{2 \, {\left (a^{4} - a^{2} b^{2}\right )} f \cos \left (f x + e\right )}, \frac {2 \, {\left (a^{3} - a b^{2}\right )} d^{2} \sin \left (f x + e\right ) + 2 \, {\left (a^{2} c^{2} - 2 \, a b c d + b^{2} d^{2}\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \cos \left (f x + e\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (f x + e\right )}\right ) \cos \left (f x + e\right ) + {\left (2 \, {\left (a^{3} - a b^{2}\right )} c d - {\left (a^{2} b - b^{3}\right )} d^{2}\right )} \cos \left (f x + e\right ) \log \left (\sin \left (f x + e\right ) + 1\right ) - {\left (2 \, {\left (a^{3} - a b^{2}\right )} c d - {\left (a^{2} b - b^{3}\right )} d^{2}\right )} \cos \left (f x + e\right ) \log \left (-\sin \left (f x + e\right ) + 1\right )}{2 \, {\left (a^{4} - a^{2} b^{2}\right )} f \cos \left (f x + e\right )}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\left (c + d \sec {\left (e + f x \right )}\right )^{2}}{a + b \cos {\left (e + f x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 203 vs.
\(2 (97) = 194\).
time = 0.49, size = 203, normalized size = 1.97 \begin {gather*} -\frac {\frac {2 \, d^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )}{{\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 1\right )} a} - \frac {{\left (2 \, a c d - b d^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 1 \right |}\right )}{a^{2}} + \frac {{\left (2 \, a c d - b d^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 1 \right |}\right )}{a^{2}} + \frac {2 \, {\left (a^{2} c^{2} - 2 \, a b c d + b^{2} d^{2}\right )} {\left (\pi \left \lfloor \frac {f x + e}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - b \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{\sqrt {a^{2} - b^{2}} a^{2}}}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 7.47, size = 2500, normalized size = 24.27 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________